package com.qf.controller;

import com.qf.pojo.req.UserReq;
import com.qf.pojo.resp.BaseResp;
import com.qf.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;

/**
 * @ClassName UserController
 * @Description TODO
 * @Author 非乐
 * @Date 2022/9/28 15:37
 * @Version 1.0
 **/

@RestController
@Api(tags = "用户管理访问")
@RequestMapping("user")
public class UserController {
    @Autowired
    UserService userService;

    @ApiOperation("注册(userName,password,userMail,code)必填")
    @PostMapping("register")
    public BaseResp register(@RequestBody UserReq userReq,HttpSession session){
        return userService.register(userReq,session);
    }

    @ApiOperation("登录(userName,password)必填")
    @PostMapping("login")
    public BaseResp login(@RequestBody UserReq userReq){
        return userService.login(userReq);
    }

    @ApiOperation("发送验证码(userMail必填)")
    @PostMapping("sendEmail")
    public BaseResp sendEmail(@RequestBody UserReq user, HttpSession session){
        BaseResp result = userService.sendEmail(user, session);
        return result;
    }

}
